package cf.huzpsb.bcgod;

import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;

public class UnbanCMD extends Command {
    public UnbanCMD(String name, String permission, String... aliases) {
        super(name, permission, aliases);
    }

    public void execute(CommandSender sender, String[] args) {
        if (!(sender instanceof ProxiedPlayer)) {
            sender.sendMessage("§c后台不推荐使用此命令");
        } else if (((ProxiedPlayer) sender).getServer().getInfo().getName().equalsIgnoreCase(Main.login)) {
            sender.sendMessage("§c登录区域禁止使用!");
            return;
        }
        if (args.length != 1) {
            sender.sendMessage("§c参数错误");
        } else {
            String tmp = args[0].replace(".", "D");
            if (Main.bancfg.contains(tmp)) {
                Main.bancfg.set(tmp, null);
                sender.sendMessage("§a解封成功!");
            } else {
                sender.sendMessage("§c查无此人!");
            }
        }
    }
}
